﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Data;
using System.IO;
using System.Drawing;
public partial class administrator_uc_admin_e_supportonline : WebPageSecurity
{
    protected void Page_Load(object sender, EventArgs e)
    {        
        if (!IsPostBack)
        {            
            if (!string.IsNullOrEmpty(Request.QueryString["itemid"]))
            {                
                LoadDataInfo(int.Parse(Request.QueryString["itemid"].ToString().Trim()));                
            }
        }
    }   
    private void LoadDataInfo(int ItemID)
    {
        DataTable dt = new BLL.CmsBLL().SupportOnline_ViewItemByID(ItemID);
        if (dt.Rows.Count > 0)
        {
            hdItemID.Value = dt.Rows[0]["SupportID"] + "";
            txtDescription.Text = dt.Rows[0]["Description"].ToString();
            txtFullName.Text = dt.Rows[0]["FullName"].ToString();
            txtAddress.Text = dt.Rows[0]["Address"].ToString();
            txtEmail.Text = dt.Rows[0]["Email"].ToString();
            txtPhoneNumber.Text = dt.Rows[0]["PhoneNumber"].ToString();
            txtYahoo.Text = dt.Rows[0]["Yahoo"].ToString();
            txtSortIndex.Text = dt.Rows[0]["SortIndex"].ToString();
            rdActive.SelectedValue = dt.Rows[0]["Active"] + "";
        }
        else
            lblMessage.Text = "Load data failt!";
    }    
    protected void lbtEditItem_Click(object sender, EventArgs e)
    {
        try
        {
            new CmsBLL().SupportOnline_UpDateItem(int.Parse(hdItemID.Value), txtDescription.Text, txtFullName.Text, txtAddress.Text, txtEmail.Text, txtPhoneNumber.Text, txtYahoo.Text, int.Parse("0" + txtSortIndex.Text.Trim()), int.Parse("0" + rdActive.SelectedValue));
            lblMessage.Text = "Cập nhật thành công!";            
        }
        catch (Exception ex)
        {
            lblMessage.Text = "ERROR! " + ex.Message.ToString();
        }
    }   
}